// 引入 Request
import Request from './index.js'
import {url1} from '@/api/common.js'

// import {mapState,mapActions} from "vuex"; 
 
 
 
const config1 = {
	baseUrl: url1,
	header: {"Content-Type": "application/json","token":uni.getStorageSync('token')},
	cancelReject: {
		text: '请求未通过验证,检查是否登录或者数据正确',
		type: 'warning'
	},
	failReject: {
		type: 'error',
		text: "网络异常，请求发送失败，请检查网络"
	}
} 

// 请求前拦截
const reqInterceptor1 = async (options) => { 
	options.header.token = uni.getStorageSync('token')  
	return options
}

// 请求前拦截
const reqInterceptor2 = async (options) => { 
	options.header.token = uni.getStorageSync('token')
	if(options.header.token ==''){
		uni.showToast({
			title:'未登录',
			icon:'none'
		}) 
		return false
	}
	return options
}
// 响应后拦截
const resInterceptor1 = (response, conf={}) => { 
	return response.data
}
const resInterceptor2 = (response, conf={}) => {
	
	return response.data
}
// 集市 正常请求
export const req1 = new Request(config1, reqInterceptor1, resInterceptor1)
 

// 集市 携带 token 请求
export const req3 = new Request(config1, reqInterceptor2, resInterceptor2)
 